home *** CD-ROM | disk | FTP | other *** search
- unit Pwd;
-
- { Password demo created by }
- { Total Data Concept AS. }
-
- { This is a example for the }
- { TPassword and TPasswordBox}
- { components. }
-
- { This code should be self- }
- { documenting. If you have }
- { any questions please send }
- { us a note via CompuServe. }
- { Read the readme.wri file }
- { for more information. }
-
- interface
-
- uses
- SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
- Forms, Dialogs, StdCtrls, Password, Grids, DBGrids, DB, DBTables,
- Pwdbox;
-
- type
- TForm1 = class(TForm)
- DataSource1: TDataSource;
- Table1: TTable;
- DBGrid1: TDBGrid;
- Password1: TPassword;
- Button1: TButton;
- Button2: TButton;
- Button3: TButton;
- Button4: TButton;
- PasswordBox1: TPasswordBox;
- procedure Button4Click(Sender: TObject);
- procedure Button3Click(Sender: TObject);
- procedure Button2Click(Sender: TObject);
- procedure Button1Click(Sender: TObject);
- procedure Password1AfterSetPassword(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure Password1AfterClearPassword(Sender: TObject);
- procedure PasswordBox1NotPassed(Sender: TObject);
- private
- { Private declarations }
-
- public
- { Public declarations }
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- {$R *.DFM}
-
- procedure TForm1.Button4Click(Sender: TObject);
- begin
- Table1.Close;
- end;
-
- procedure TForm1.Button3Click(Sender: TObject);
- begin
- try
- Table1.Open;
- except
- end;
- end;
-
- procedure TForm1.Button2Click(Sender: TObject);
- begin
- { Clear the password and remove session passwords }
- Password1.ClearPassword;
- end;
-
- procedure TForm1.Button1Click(Sender: TObject);
- var
- PwdString: string;
- begin
- { Query and set password... }
- { InputQuery does not mask any inputcharacters, but
- is used for demonstration purposes only.. }
- PwdString := 'MyPassword';
- if InputQuery('TPassword Demo','Enter Password', PwdString) then
- Password1.SetPassword(PwdString);
- end;
-
- procedure TForm1.Password1AfterSetPassword(Sender: TObject);
- begin
- { Remove this line to keep the session password }
- Session.RemoveAllPasswords;
-
- { Need to reset the password counter }
- PasswordBox1.Reset;
- end;
-
- procedure TForm1.Password1AfterClearPassword(Sender: TObject);
- begin
- PasswordBox1.Reset;
- end;
-
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- try
- Table1.Open;
- except
- end;
- end;
-
- procedure TForm1.PasswordBox1NotPassed(Sender: TObject);
- begin
- MessageDlg('No no no ... wrong password...', mtInformation, [mbOk], 0);
- end;
-
- end.
-